package com.example.lenovo.wechat;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class WeixinFragment extends Fragment {

    public List<Session> mSessions;

    public WeixinFragment() {
        mSessions = new ArrayList<>();
        mSessions.add(new Session(R.mipmap.ic_launcher, "回话1"));
        mSessions.add(new Session(R.mipmap.ic_launcher_round, "回话2"));
        mSessions.add(new Session(R.mipmap.ic_launcher, "回话3"));
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.weixin_frag,container,false);
    }
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        RecyclerView rlvSessions = getActivity().findViewById(R.id.rlv_wechat_sessions);
        rlvSessions.setLayoutManager(new LinearLayoutManager(getContext()));

        SessionAdapter adapter = new SessionAdapter(mSessions);
        rlvSessions.setAdapter(adapter);
    }
}
